package design.mode.flyweight.item3;

import java.util.ArrayList;
import java.util.List;
import org.omg.CORBA.PUBLIC_MEMBER;

/**
 * @author ZhongMingde on 2021/11/4
 */

public class CharacterStyleFactory {

  private static final List<CharacterStyle> styles = new ArrayList<>();

  public static CharacterStyle getStyle(Font font, int size, int colorRGB) {
    CharacterStyle newStyle = new CharacterStyle(font, size, colorRGB);
    for (CharacterStyle style : styles) {
      if (style.equals(newStyle)) {
        return style;
      }
    }
    styles.add(newStyle);
    return newStyle;
  }

}
